using System.Windows.Forms;
using Infragistics.Win;

namespace PcrDataAnalysis
{
	public class CheckEditorStringDataFilter : IEditorDataFilter
	{
		object IEditorDataFilter.Convert(EditorDataFilterConvertArgs args)
		{
			switch (args.Direction)
			{
			case ConversionDirection.EditorToOwner:
				args.Handled = true;
				switch ((CheckState)args.Value)
				{
				case CheckState.Checked:
					return "Y";
				case CheckState.Unchecked:
					return "N";
				case CheckState.Indeterminate:
					return "?";
				}
				break;
			case ConversionDirection.OwnerToEditor:
				args.Handled = true;
				if (args.Value.ToString() == "Y")
				{
					return CheckState.Checked;
				}
				if (args.Value.ToString() == "N")
				{
					return CheckState.Unchecked;
				}
				return CheckState.Indeterminate;
			}
			return args.Value;
		}
	}
}
